//引入集合模型
const { questionsModel } = require("../models/questionsModel");
const { usersModel } = require("../models/usersModel");
const { knowledgePointsModel } = require("../models/knowledgePointsModel");
const { examTypeModel } = require("../models/examTypeModel");
const { testsModel } = require("../models/testsModel");
const {
    completedTestModel
} = require("../models/completedTestModel");





async function getAllTest(req, res, next) {

    let allTestsArr = await testsModel.find({}).populate('KnowledgePointId').populate('TypeId');

    res.send({ code: 1, allTestsArr });
}
//排名(排序前端排序)
async function ranking(req, res, next) {

    let { test_id } = req.body;
    let userTestsArr = await completedTestModel.find({test_id}).populate('test_id').populate('user_id');
    res.send({ code: 1, userTestsArr});
   
}





module.exports = {
    //导出的函数名
    getAllTest, ranking
}